/**
* @author Ashish Gupta
* CVSSP, University of Surrey
* Copyright (c) 2010 Ashish Gupta
* All rights reserved.
*/
/**
 * 
 */
package genetic;

import classification.VisualCodebook;

/**
 * @author Ashish
 *
 */
public class BhattacharyaMetric extends FitnessFunction {

	/* (non-Javadoc)
	 * @see genetic.FitnessFunction#calcFitness()
	 */
	@Override
	public Double calcFitness(VisualCodebook visualCodebook) {
		double fitness = 0.0;
		for(int i =0; i < visualCodebook.getPositiveHistogram().length;i++){
			double pos = Math.sqrt(visualCodebook.getPositiveHistogram()[i]);
			double neg = Math.sqrt(visualCodebook.getNegativeHistogram()[i]);
			fitness += pos*neg;
		}
		return fitness;
	}

}
